using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.Production
{
    public class ProductionOrderAutoMapperProfile : Profile
    {
        public ProductionOrderAutoMapperProfile()
        {
            CreateMap<ProductionOrder, ProductionOrderDto>().MapExtraProperties().ReverseMap();
            CreateMap<ProductionOrder, ProductionOrderDocumentDto>().MapExtraProperties().ReverseMap();
            CreateMap<ProductionOrder, ProductionOrderCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<ProductionOrder, ProductionOrderUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<ProductionOrderUpdateDto, ProductionOrder>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.OrderType, opt => opt.Ignore())
                .ForMember(dest => dest.ItemMaster, opt => opt.Ignore())
                .MapChildren<ProductionOrderUpdateDto, ProductionOrder, ProductionOrderPreparationCreateOrUpdateDto, ProductionOrderPreparation>();

            CreateMap<ProductionOrderPreparation, ProductionOrderPreparationDto>().MapExtraProperties().ReverseMap();
            CreateMap<ProductionOrderPreparation, ProductionOrderPreparationCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
} 